package com.example.arrayadapter;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;

public class MainActivity extends Activity {

	ArrayAdapter<String> adapter;
	String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
	        "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
	        "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
	        "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2",
	        "Android", "iPhone", "WindowsMobile" };
	ListView listview;
	ArrayList<String> list;

	  @Override
	  protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_main);

	    listview = (ListView) findViewById(R.id.lsvEmployee);
	    

//	    final ArrayList<String> list = new ArrayList<String>();
	    list = new ArrayList<String>();
	    for (int i = 0; i < values.length; ++i) {
	      list.add(values[i]);
	    }
	    adapter = new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1, list);
	    listview.setAdapter(adapter);

	    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

		      @Override
		      public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
		    	  		String item = (String) parent.getItemAtPosition(position);
		                adapter.remove(item);
		                Log.i("count", String.valueOf(list.size()));
		                //
		                //
		                
	
		      }
	    });
	  }
}